var union = require('union');

var request = require('request');
var weixin = require('./weixin');

var server = union.createServer({
    before: [
        function (req, res) {
            console.log("\n---------------------------------------------------------------------------------------");
            console.log('\n收到请求:' + req.url);
            res.emit('next');
        },
        function (req, res) {
            //是否是微信接口
            if(req.url.indexOf('/wechat/') != -1){
                console.log("\n 微信处理");
                weixin.service(req,res);
            }else{
                console.log("\n 非法请求");
                res.end("error");
            }
        }
    ]
});
server.listen(80);
console.log("\weixin服务启动 监听端口 ：80");